--------------------------------------------------------
-- Archivo creado  - viernes-febrero-27-2015   
--------------------------------------------------------
--------------------------------------------------------
--  DDL for Sequence EMPRESA_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "ESSALUD"."EMPRESA_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Sequence PERFIL_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "ESSALUD"."PERFIL_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Sequence PERSONA_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "ESSALUD"."PERSONA_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Sequence USUARIO_SEQ
--------------------------------------------------------

   CREATE SEQUENCE  "ESSALUD"."USUARIO_SEQ"  MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 NOORDER  NOCYCLE ;
--------------------------------------------------------
--  DDL for Table EMPRESA
--------------------------------------------------------

  CREATE TABLE "ESSALUD"."EMPRESA" 
   (	"ID" NUMBER, 
	"RAZONSOCIAL" VARCHAR2(50 BYTE), 
	"RUC" VARCHAR2(20 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table PERFIL
--------------------------------------------------------

  CREATE TABLE "ESSALUD"."PERFIL" 
   (	"DESCRIPCION" VARCHAR2(250 BYTE), 
	"ID" NUMBER
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table PERMISO
--------------------------------------------------------

  CREATE TABLE "ESSALUD"."PERMISO" 
   (	"AUTORIDAD" VARCHAR2(20 BYTE), 
	"DESCRIPCION" VARCHAR2(250 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table PERMISOXPERFIL
--------------------------------------------------------

  CREATE TABLE "ESSALUD"."PERMISOXPERFIL" 
   (	"PERFIL" NUMBER, 
	"AUTORIDAD" VARCHAR2(20 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table PERSONA
--------------------------------------------------------

  CREATE TABLE "ESSALUD"."PERSONA" 
   (	"ID" NUMBER, 
	"NOMBRES" VARCHAR2(50 BYTE), 
	"DNI" VARCHAR2(20 BYTE)
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Table USUARIO
--------------------------------------------------------

  CREATE TABLE "ESSALUD"."USUARIO" 
   (	"ID" NUMBER, 
	"LOGIN" VARCHAR2(50 BYTE), 
	"PASSWORD" VARCHAR2(250 BYTE), 
	"FLAGACTIVO" NUMBER(1,0), 
	"PERFIL" NUMBER, 
	"FLAGBAJA" NUMBER(1,0), 
	"TIPO" VARCHAR2(10 BYTE), 
	"CORREO" VARCHAR2(50 BYTE), 
	"PERSONA" NUMBER, 
	"EMPRESA" NUMBER
   ) SEGMENT CREATION IMMEDIATE 
  PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
REM INSERTING into ESSALUD.EMPRESA
SET DEFINE OFF;
Insert into ESSALUD.EMPRESA (ID,RAZONSOCIAL,RUC) values ('1','Eureka EIRL','20985748565');
Insert into ESSALUD.EMPRESA (ID,RAZONSOCIAL,RUC) values ('2','Sol SAC','20123565659');
Insert into ESSALUD.EMPRESA (ID,RAZONSOCIAL,RUC) values ('3','Luna SA','20145877515');
REM INSERTING into ESSALUD.PERFIL
SET DEFINE OFF;
Insert into ESSALUD.PERFIL (DESCRIPCION,ID) values ('Administrador','1');
Insert into ESSALUD.PERFIL (DESCRIPCION,ID) values ('Proveedor','2');
REM INSERTING into ESSALUD.PERMISO
SET DEFINE OFF;
Insert into ESSALUD.PERMISO (AUTORIDAD,DESCRIPCION) values ('ROLE_ADMIN','Administrador');
Insert into ESSALUD.PERMISO (AUTORIDAD,DESCRIPCION) values ('ROLE_PROVEEDOR','Proveedor');
REM INSERTING into ESSALUD.PERMISOXPERFIL
SET DEFINE OFF;
Insert into ESSALUD.PERMISOXPERFIL (PERFIL,AUTORIDAD) values ('1','ROLE_ADMIN');
Insert into ESSALUD.PERMISOXPERFIL (PERFIL,AUTORIDAD) values ('2','ROLE_PROVEEDOR');
REM INSERTING into ESSALUD.PERSONA
SET DEFINE OFF;
Insert into ESSALUD.PERSONA (ID,NOMBRES,DNI) values ('1','Ricardo Perez','84548968');
Insert into ESSALUD.PERSONA (ID,NOMBRES,DNI) values ('2','Manuel Yamamori','84356794');
Insert into ESSALUD.PERSONA (ID,NOMBRES,DNI) values ('3','John Snow','84787874');
REM INSERTING into ESSALUD.USUARIO
SET DEFINE OFF;
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('14','personaAltaaa','2c7febb102a46ef080d52310185a8375cd025c04','0','1','0','Persona','persona@alt.comaaa','1',null);
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('10','prueba','711383a59fda05336fd2ccf70c8059d1523eb41a','1','1','1','Otro','prueba@prueba.com',null,null);
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('13','proveedorAlt','16e98c2b3c75db7ec5684ee1bce0fc4e2b3f3909','0','2','0','Empresa','proveedor@alt.com',null,'2');
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('15','persona2','e26f7b1fc138d6344b31d376ccd50e7f47e37732','1','1','0','Persona','persona@2.com','2',null);
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('16','prueba1','096459e93f20a2b39ab6c5ddd493e44f58bc3a91','1','2','0','Empresa','prueba1@p.com',null,'3');
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('17','prueba3','ee5ed95c37d99b7a07981ce3bda95ad246d784e5','1','1','0','Persona','sadas@asdfas.cpm','2',null);
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('18','prueba4','df63e116b19a23e1a34c221c994a3d7b64fe372d','0','1','0','Otro','prueba@4.com',null,null);
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('19','prueba5','64e88993cfab6de9053885f277ad298d99405282','1','2','0','Empresa','prueba@5.com',null,'3');
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('1','admin','d033e22ae348aeb5660fc2140aec35850c4da997','1','1','0','Otro',null,null,null);
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('2','proveedor','3711da0958245dc019c4a9348ee9f09e3b2250ee','1','2','0','Empresa','proveedor@proveedor.com',null,'1');
Insert into ESSALUD.USUARIO (ID,LOGIN,PASSWORD,FLAGACTIVO,PERFIL,FLAGBAJA,TIPO,CORREO,PERSONA,EMPRESA) values ('4','persona','1c6027c0667c7646b964476b61960e0cf7b559ee','1','1','0','Persona','persona@persona.com','1',null);
--------------------------------------------------------
--  DDL for Index EMPRESA_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "ESSALUD"."EMPRESA_PK" ON "ESSALUD"."EMPRESA" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index PERFIL_PK1
--------------------------------------------------------

  CREATE UNIQUE INDEX "ESSALUD"."PERFIL_PK1" ON "ESSALUD"."PERFIL" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index PERMISO_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "ESSALUD"."PERMISO_PK" ON "ESSALUD"."PERMISO" ("AUTORIDAD") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index PERMISOXPERFIL_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "ESSALUD"."PERMISOXPERFIL_PK" ON "ESSALUD"."PERMISOXPERFIL" ("PERFIL", "AUTORIDAD") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index PERSONA_PK
--------------------------------------------------------

  CREATE UNIQUE INDEX "ESSALUD"."PERSONA_PK" ON "ESSALUD"."PERSONA" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index USUARIO_PK1
--------------------------------------------------------

  CREATE UNIQUE INDEX "ESSALUD"."USUARIO_PK1" ON "ESSALUD"."USUARIO" ("ID") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  DDL for Index UNIQUE_LOGIN
--------------------------------------------------------

  CREATE UNIQUE INDEX "ESSALUD"."UNIQUE_LOGIN" ON "ESSALUD"."USUARIO" ("LOGIN") 
  PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS" ;
--------------------------------------------------------
--  Constraints for Table EMPRESA
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."EMPRESA" ADD CONSTRAINT "EMPRESA_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "ESSALUD"."EMPRESA" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table PERFIL
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."PERFIL" ADD CONSTRAINT "PERFIL_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "ESSALUD"."PERFIL" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table PERMISO
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."PERMISO" ADD CONSTRAINT "PERMISO_PK" PRIMARY KEY ("AUTORIDAD")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "ESSALUD"."PERMISO" MODIFY ("AUTORIDAD" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table PERMISOXPERFIL
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."PERMISOXPERFIL" ADD CONSTRAINT "PERMISOXPERFIL_PK" PRIMARY KEY ("PERFIL", "AUTORIDAD")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "ESSALUD"."PERMISOXPERFIL" MODIFY ("AUTORIDAD" NOT NULL ENABLE);
  ALTER TABLE "ESSALUD"."PERMISOXPERFIL" MODIFY ("PERFIL" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table PERSONA
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."PERSONA" ADD CONSTRAINT "PERSONA_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "ESSALUD"."PERSONA" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Constraints for Table USUARIO
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."USUARIO" ADD CONSTRAINT "UNIQUE_LOGIN" UNIQUE ("LOGIN")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "ESSALUD"."USUARIO" MODIFY ("FLAGACTIVO" NOT NULL ENABLE);
  ALTER TABLE "ESSALUD"."USUARIO" ADD CONSTRAINT "USUARIO_PK" PRIMARY KEY ("ID")
  USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS 
  STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
  PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
  TABLESPACE "USERS"  ENABLE;
  ALTER TABLE "ESSALUD"."USUARIO" MODIFY ("PASSWORD" NOT NULL ENABLE);
  ALTER TABLE "ESSALUD"."USUARIO" MODIFY ("LOGIN" NOT NULL ENABLE);
  ALTER TABLE "ESSALUD"."USUARIO" MODIFY ("ID" NOT NULL ENABLE);
--------------------------------------------------------
--  Ref Constraints for Table PERMISOXPERFIL
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."PERMISOXPERFIL" ADD CONSTRAINT "PERMISOXPERFIL_FK1" FOREIGN KEY ("PERFIL")
	  REFERENCES "ESSALUD"."PERFIL" ("ID") ENABLE;
  ALTER TABLE "ESSALUD"."PERMISOXPERFIL" ADD CONSTRAINT "PERMISOXPERFIL_FK2" FOREIGN KEY ("AUTORIDAD")
	  REFERENCES "ESSALUD"."PERMISO" ("AUTORIDAD") ENABLE;
--------------------------------------------------------
--  Ref Constraints for Table USUARIO
--------------------------------------------------------

  ALTER TABLE "ESSALUD"."USUARIO" ADD CONSTRAINT "USUARIO_FK1" FOREIGN KEY ("PERFIL")
	  REFERENCES "ESSALUD"."PERFIL" ("ID") ENABLE;
  ALTER TABLE "ESSALUD"."USUARIO" ADD CONSTRAINT "USUARIO_FK2" FOREIGN KEY ("PERSONA")
	  REFERENCES "ESSALUD"."PERSONA" ("ID") ENABLE;
  ALTER TABLE "ESSALUD"."USUARIO" ADD CONSTRAINT "USUARIO_FK3" FOREIGN KEY ("EMPRESA")
	  REFERENCES "ESSALUD"."EMPRESA" ("ID") ENABLE;
--------------------------------------------------------
--  DDL for Trigger EMPRESA_TRG
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "ESSALUD"."EMPRESA_TRG" 
BEFORE INSERT ON EMPRESA 
FOR EACH ROW 
BEGIN
  <<COLUMN_SEQUENCES>>
  BEGIN
    IF INSERTING AND :NEW.ID IS NULL THEN
      SELECT EMPRESA_SEQ.NEXTVAL INTO :NEW.ID FROM SYS.DUAL;
    END IF;
  END COLUMN_SEQUENCES;
END;
/
ALTER TRIGGER "ESSALUD"."EMPRESA_TRG" ENABLE;
--------------------------------------------------------
--  DDL for Trigger PERFIL_TRG
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "ESSALUD"."PERFIL_TRG" 
BEFORE INSERT ON PERFIL 
FOR EACH ROW 
BEGIN
  <<COLUMN_SEQUENCES>>
  BEGIN
    IF INSERTING AND :NEW.ID IS NULL THEN
      SELECT PERFIL_SEQ.NEXTVAL INTO :NEW.ID FROM SYS.DUAL;
    END IF;
  END COLUMN_SEQUENCES;
END;
/
ALTER TRIGGER "ESSALUD"."PERFIL_TRG" ENABLE;
--------------------------------------------------------
--  DDL for Trigger PERSONA_TRG
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "ESSALUD"."PERSONA_TRG" 
BEFORE INSERT ON PERSONA 
FOR EACH ROW 
BEGIN
  <<COLUMN_SEQUENCES>>
  BEGIN
    IF INSERTING AND :NEW.ID IS NULL THEN
      SELECT PERSONA_SEQ.NEXTVAL INTO :NEW.ID FROM SYS.DUAL;
    END IF;
  END COLUMN_SEQUENCES;
END;
/
ALTER TRIGGER "ESSALUD"."PERSONA_TRG" ENABLE;
--------------------------------------------------------
--  DDL for Trigger USUARIO_TRG
--------------------------------------------------------

  CREATE OR REPLACE TRIGGER "ESSALUD"."USUARIO_TRG" 
BEFORE INSERT ON USUARIO 
FOR EACH ROW 
BEGIN
  <<COLUMN_SEQUENCES>>
  BEGIN
    IF INSERTING AND :NEW.ID IS NULL THEN
      SELECT USUARIO_SEQ.NEXTVAL INTO :NEW.ID FROM SYS.DUAL;
    END IF;
  END COLUMN_SEQUENCES;
END;
/
ALTER TRIGGER "ESSALUD"."USUARIO_TRG" ENABLE;